from framwork.common.tools  import open_browsers
from time import sleep
from selenium.webdriver.common.by import By

"""添加短信模版 ok"""
#数据
url=r"http://192.168.1.23/crm/index.php?m=user&a=login"
user_name="admin"
passwd="123456"
title="中秋快乐"
text="月圆人团圆，灯火映笑颜。愿你中秋的每一刻，都被温柔月光轻轻拥抱：家人围坐，茶香弥漫；朋友千里，祝福相连；事业如月升，步步皆圆满；心似月华，清澈又平安。桂香浮动时，幸福已落在你的窗前。中秋快乐，阖家安康！"
#定位器
username_locator=(By.NAME,"name")
password_locator=(By.NAME,"password")
login_btn_locator=(By.NAME,"submit")
gd_locator=(By.LINK_TEXT,"更多")
yx_locator=(By.LINK_TEXT,"营销")
setmodel_locator=(By.LINK_TEXT,"设置")
addmodel_locator=(By.CSS_SELECTOR,"#add")
title_locator=(By.XPATH,"/html/body/div[7]/div[2]/form/table/tbody/tr[2]/td[2]/input")

text_locator=(By.NAME,"content")
btn_locator=(By.NAME,"submit")
#操作
driver=open_browsers()
driver.get(url)
sleep(3)
driver.find_element(*username_locator).send_keys(user_name)
driver.find_element(*password_locator).send_keys(passwd)
driver.find_element(*login_btn_locator).click()
sleep(1)
driver.find_element(*gd_locator).click()
sleep(1)
driver.find_element(*yx_locator).click()
sleep(1)
driver.find_element(*setmodel_locator).click()
sleep(1)
driver.find_element(*addmodel_locator).click()
sleep(1)
driver.find_element(*title_locator).send_keys(title)
sleep(1)
driver.find_element(*text_locator).send_keys(text)
sleep(1)
driver.find_element(*btn_locator).click()
sleep(1)
#退出浏览器
sleep(3)
driver.close()